package pe.edu.unmsm.fisi.sisconteg.business.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import pe.edu.unmsm.fisi.sisconteg.business.service.AlumnoService;
import pe.edu.unmsm.fisi.sisconteg.domain.model.Alumno;
import pe.edu.unmsm.fisi.sisconteg.repository.dao.AlumnoDAO;

@SuppressWarnings("serial")
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class AlumnoServiceImpl implements AlumnoService, java.io.Serializable {

	@Resource
	private AlumnoDAO alumnoDAO;
	
	@Override
	public Alumno validarDatos(String codAlumno, String dni) throws DataAccessException {
		Alumno alumno;
		alumno = alumnoDAO.getAlumnoxCodigo(codAlumno);
		if (alumno == null)
			return null;
		
		if (!alumno.getDni().equals(dni))
			return null;
		
		return alumno;
	}

	@Override
	public Alumno getAlumnoxCodigo(String codAlumno) throws DataAccessException {
		return alumnoDAO.getAlumnoxCodigo(codAlumno);
	}

	@Override
	public List<Alumno> getAlumnosxNombres(String nombres)
			throws DataAccessException {
		return alumnoDAO.getAlumnosxNombres(nombres);
	}

}
